﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using JumbotCms.API;
namespace JumbotCms.Modules.Video.Plus
{
    public partial class _play : JumbotCms.API.FrontHtml
    {
        protected void Page_Unload(object sender, EventArgs e)
        {
            SavePageLog(1);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Server.ScriptTimeout = 5;//脚本过期时间
            string id = Str2Str(q("id"));
            int down = Str2Int(q("no"));
            int vWidth = Str2Int(q("w")) == 0 ? 400 : Str2Int(q("w"));
            int vHeight = Str2Int(q("h")) == 0 ? 300 : Str2Int(q("h"));
            string vAutoStart = q("auto") != "0" ? "true" : q("auto");
            string vAutoPlay = q("auto") != "0" ? "1" : q("auto");
            string _html = string.Empty;
            if (id == "0")
            {
                _html = "<img src=\"" + site.Dir + "publicstyle/video_play.jpg\" border=\"0\" width=\"" + vWidth + "\" height=\"" + vHeight + "\" />";
            }
            else
            {
                doh.Reset();
                doh.ConditionExpress = "id=" + id;
                string videoUrl = doh.GetValue("jcms_module_video", "VideoUrl").ToString().Replace("\r\n", "\r");
                if (videoUrl != "")
                {
                    string[] _VideoUrl = videoUrl.Split(new string[] { "\r" }, StringSplitOptions.None);
                    int _NO = Jumbot.Common.Validator.StrToInt(q("NO"), 0);//第几个地址
                    string _txt = "片段[" + (_NO + 1) + "]";
                    string _url = _VideoUrl[_NO];
                    //if (_url.IndexOf("|||") > 0)
                    if (_url.Contains("|||"))
                    {
                        _txt = _url.Substring(0, _url.IndexOf("|||"));
                        _url = _url.Substring(_url.IndexOf("|||") + 3, (_url.Length - _url.IndexOf("|||") - 3));
                    }
                    string _ext = Jumbot.Common.DirFile.GetFileExt(_url);
                    switch (_ext)
                    {
                        case "asf":
                            _html = "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902\" type=\"application/x-oleobject\" standby=\"Loading...\" width=\"" + vWidth + "\" height=\"" + vHeight + "\"><param name=\"FileName\" VALUE=\"" + _url + "\" /><param name=\"ShowStatusBar\" value=\"-1\" /><param name=\"AutoStart\" value=\"" + vAutoStart + "\" /><embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" src=\"" + _url + "\" autostart=\"" + vAutoStart + "\" width=\"" + vWidth + "\" height=\"" + vHeight + "\" /></object>";
                            break;
                        case "avi":
                            _html = "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902\" type=\"application/x-oleobject\" standby=\"Loading...\" width=\"" + vWidth + "\" height=\"" + vHeight + "\"><param name=\"FileName\" VALUE=\"" + _url + "\" /><param name=\"ShowStatusBar\" value=\"-1\" /><param name=\"AutoStart\" value=\"" + vAutoStart + "\" /><embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" src=\"" + _url + "\" autostart=\"" + vAutoStart + "\" width=\"" + vWidth + "\" height=\"" + vHeight + "\" /></object>";
                            break;
                        case "wmv":
                            _html = "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902\" type=\"application/x-oleobject\" standby=\"Loading...\" width=\"" + vWidth + "\" height=\"" + vHeight + "\"><param name=\"FileName\" VALUE=\"" + _url + "\" /><param name=\"ShowStatusBar\" value=\"-1\" /><param name=\"AutoStart\" value=\"" + vAutoStart + "\" /><embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" src=\"" + _url + "\" autostart=\"" + vAutoStart + "\" width=\"" + vWidth + "\" height=\"" + vHeight + "\" /></object>";
                            break;
                        case "swf":
                            _html = "<object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + vWidth + "\" height=\"" + vHeight + "\"><param name=\"movie\" value=\"" + _url + "\" /><param name=\"quality\" value=\"high\" /><param name=\"AllowScriptAccess\" value=\"never\" /><embed src=\"" + _url + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + vWidth + "\" height=\"" + vHeight + "\" /></object>";
                            break;
                        default:
                            _html = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + vWidth + "\" height=\"" + vHeight + "\"><param name=\"movie\" value=\"" + site.Dir + "publicstyle/vcastr22.swf\"><param name=\"quality\" value=\"high\"><param name=\"allowFullScreen\" value=\"true\"><param name=\"FlashVars\" value=\"vcastr_file=" + _url + "&vcastr_title=" + _txt + "&BarColor=0xFF6600&BarPosition=1&IsAutoPlay=" + vAutoPlay + "\" /><embed src=\"" + site.Dir + "publicstyle/vcastr22.swf\" allowFullScreen=\"true\" FlashVars=\"vcastr_file=" + _url + "&vcastr_title=" + _txt + "&BarColor=0xFF6600&BarPosition=1\" quality=\"high\" width=\"" + vWidth + "\" height=\"" + vHeight + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></object>";
                            break;
                    }
                }
                else
                    _html = "<img src=\"" + site.Dir + "publicstyle/video_play.jpg\" border=\"0\" width=\"" + vWidth + "\" height=\"" + vHeight + "\" />";
            }
            Response.Write("<html><body style=\"margin:0px;padding:0px;\"><div style=\"margin:0px;padding:0px;\">" + _html + "</div></body></html>");
        }
    }
}
